package Hot100.Easy.LC101;

public class LC101 {
    public static void main(String[] args){
        TreeNode root=new TreeNode(1);
        root.left=new TreeNode(2);
        root.right=new TreeNode(2);
        root.left.left=new TreeNode(3);
        root.left.right=new TreeNode(4);
        root.right.left=new TreeNode(4);
        root.right.right=new TreeNode(3);
        LC101 solution = new LC101();
        System.out.println(solution.isSymmetric(root));

    }

    public boolean isSymmetric(TreeNode root){
        if(root==null)
        {
            return true;
        }
        else {
            return recur(root.left,root.right);
        }
    }
    public boolean recur(TreeNode l, TreeNode r){
        if(l==null && r==null) {
            return true;
        }
        else if(l==null||r==null||l.val!=r.val){
            return false;
        }
        return recur(l.left,r.right)&&recur(l.right,r.left);

    }

}
